﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CustomerInfo.aspx.cs" Inherits="BEGDC.CC.Web.CIS2.Overseas.CustomerInfo" %>

<%@ Import Namespace="System.Linq" %>
<%@ Import Namespace="ASBCC.Database.EntityFramework" %>
<%@ Register Src="../../UserControls/Pager.ascx" TagName="Pager" TagPrefix="cc" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <link href="../../css/global.css" rel="stylesheet" type="text/css" />
    <link href="../../css/main.css" rel="stylesheet" type="text/css" />
    <link href="../../css/content/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" />
    <link href="../../css/content/entity.css" rel="stylesheet" type="text/css" />

    <script src="../../js/jquery-1.4.4.min.js" type="text/javascript"></script>

    <script src="../../js/jquery-ui.min.js" type="text/javascript"></script>

    <script src="../../js/entity.js.aspx" type="text/javascript"></script>

    <script src="../../js/jquery.cascade.js" type="text/javascript"></script>

    <script src="../../js/jquery.cascade.ext.js" type="text/javascript"></script>

    <script src="../../js/jquery.templating.js" type="text/javascript"></script>

    <style type="text/css">
        .label-company
        {
            color: Red;
        }
        .entity-row
        {
            clear: both;
        }
        .entity-row input
        {
            float: none;
        }
        .educations-table
        {
            padding: 2px;
        }
        .familyinfo-table
        {
            padding: 2px;
        }
        .workexperience-table
        {
            padding: 2px;
        }
        .educations-delete, .familyinfo-delete, .workexperience-delete, .preference-delete, .training-delete
        {
            margin-top: 4px;
            width: 15px;
            height: 15px;
            display: inline-block;
            background-image: url(../../css/content/images/delete.gif);
        }
        .edu, .work
        {
            display: inline;
            float: left;
            width: 330px;
            margin-right: 10px;
        }
        .edu span
        {
            font-style: italic;
            float: left;
        }
        .degree
        {
            display: inline;
            float: left;
            width: 275px;
        }
        .degree span
        {
            font-style: italic;
            float: left;
        }
        .rel
        {
            display: inline;
            float: left;
            width: 225px;
        }
        .rel span
        {
            font-style: italic;
            float: left;
        }
        .hr
        {
            height: 1px;
            border-bottom: dashed 1px #ccc;
            clear: both;
            overflow: hidden;
        }
        .work input
        {
            font-style: italic;
            float: left;
        }
        .work span
        {
            width: 300px;
            font-style: italic;
            float: left;
        }
        .work img
        {
            float: left;
        }
        .train
        {
            float: left;
            width: 670px;
        }
        .fl
        {
            float: left;
        }
        .selected-bg
        {
            color: White;
            background-color: #773460;
        }
        .select-b-container
        {
            width: 330px;
            height: 165px;
            overflow: auto;
            margin-top: 10px;
            cursor: pointer;
            border-color: #ccc;
            border-style: solid;
            border-width: 1px;
        }
        ul.CreatCompany
        {
            line-height: 175%;
        }
        ul.CreatCompany li
        {
            width: 320px;
            float: left;
        }
        ul.CreatCompany span
        {
            width: 130px;
            float: left;
            background: #f7f7f7;
            padding-left: 5px;
        }
        ul.CreatCompany .Red
        {
            color: Red;
        }
        ul.CreatCompany select
        {
            width: 175px;
        }
        .widthInfo
        {
            width: 200px;
        }
        .widthInfo input
        {
            width: 200px;
        }
        .tablestyle2 select
        {
            width: 200px;
            color: #3a3a3a;
            font-size: 100%;
        }
        .tablestyle2 input[type="text"]
        {
            height: 14px;
            padding-top: 2px;
            color: #3a3a3a;
            font-size: 100%;
            width: 200px;
            border: 1px solid #ccc;
        }
        input.width165
        {
            width: 165px;
        }
        input.width220
        {
            width: 200px;
        }
        .preference-table select
        {
            width: 165px;
            color: #3a3a3a;
            font-size: 100%;
        }
        .preference-table input[type="text"]
        {
            height: 14px;
            padding-top: 2px;
            color: #3a3a3a;
            font-size: 100%;
            width: 165px;
            border: 1px solid #ccc;
        }
    </style>

    <script type="text/javascript">
        var List=<%=GetPreferencesList() %>;
        var value=<%=GetPreferencesValue()%>;
        var Level=<%=GetPreferencesLevel()%>;
        function commonTemplate(item) {
            return "<option value='" + item.Value + "'>" + item.Text + "</option>";
        };
        function commonMatch(selectedValue) {
            return this.When == selectedValue;
        };
       var opts1 = {                list: value,				template: commonTemplate,				match: commonMatch 		};				var opts2 = {                list: Level,				template: commonTemplate,				match: commonMatch 		};
        $(function() {
             if($("#edSelect").length>0)
        {
            var preferenceBinding = function(v, l){
                v.each(function() {				    var child = $(this);				    child.parents(".container-2:first").siblings(".container-1").find("select").each(function() {					    child.cascade($(this),opts1);									    });			    });
    			
			    l.each(function() {				    var child = $(this);				    child.parents(".container-3:first").siblings(".container-1").find("select").each(function() {					    child.cascade($(this),opts2);									    });			    });	            
            };  
            
            var departmentSelect=$("#edSelect");
            var deparmentstring ="";
            var value1=departmentSelect.val();
            var params = '{}';
            $.ajax({
            type: "POST",
            url: "CustomerInfo.aspx/GetDeparmentSelect",
            data: params,
            dataType: "json",
            contentType: "application/json; charset=utf-8",
            success: function(result) {
                deparmentstring = result.d;
                var deparmentObj = jQuery.parseJSON(deparmentstring);
                var optiondepartmentstring="";
                var optiondepartmentstring2="";
                for(var item in deparmentObj)
                {
                    optiondepartmentstring += "<option class=\"option-department\" value=\""+ deparmentObj[item] +"\" >"+ item +"</option>";
                    optiondepartmentstring2 += "<div vv=\""+deparmentObj[item]+"\" class=\"div-item\">"+item+"</div>"
                }
                departmentSelect.html(optiondepartmentstring);
                $("#department-list-b").html(optiondepartmentstring2);
                departmentSelect.val(value1);
            },
            error: function(xhr, msg, e) {  
                alert("error");
            }
            });
                
            var roles='<%=GetRoleIDs() %>';
            var companystring="";
            var companySelect=$("#company-list-a");
            var value2 = companySelect.val();
            params= '{roles:"'+roles+'"}';
            $.ajax({
            type: "POST",
            url: "CustomerInfo.aspx/GetCompanySelect",
            data: params,
            dataType: "json",
            contentType: "application/json; charset=utf-8",
            success: function(result) {
                companystring = result.d;
                var companyObj = jQuery.parseJSON(companystring);
                var optioncompanystring="";
                var optioncompanystring2="";
                for(var item in companyObj)
                {
                    optioncompanystring += "<option value=\""+ companyObj[item] +"\" >"+ item +"</option>";
                    optioncompanystring2 += "<div vv=\""+companyObj[item]+"\" class=\"div-item\">"+item+"</div>"
                }
                companySelect.html(optioncompanystring);
                $("#company-list-b").html(optioncompanystring2);
                companySelect.val(value2);
            },
            error: function(xhr, msg, e) {  
                alert("error");
            }
            });
            
            $(".check-name").bind("change",function(){
                var customerName=$(".check-name").val();
                if(customerName!="")
                {
                    params= '{name:"'+customerName+'",roles:"'+roles+'"}'
                    $.ajax({
                    type: "POST",
                    url: "CustomerInfo.aspx/CheckCustomerName",
                    data: params,
                    dataType: "json",
                    contentType: "application/json; charset=utf-8",
                    success: function(result) {
                        var checkresult = result.d;
                        if(checkresult=="0")
                            $("#name_identity").text("");
                        if(checkresult=="1")
                            {
                            $("#name_identity").text("[姓名重复!]");
                            }
                    },
                    error: function(xhr, msg, e) {  
                        alert("error");
                    }
                    });
                }
                
            });
            
            
            $(".entity-level").val($(".entity-level").attr("u"));
            $(".entity-gender").val($(".entity-gender").attr("u"));
            $(".entity-definition").val($(".entity-definition").attr("u"));
            $(".insert-company").val($(".insert-company").attr("u"));
            $(".entity-Degree").each(function(){
                var child = jQuery(this);
                child.val(child.attr("u"));
            });
           

            var rmline = function(e) {
                e.parent().remove();
            };
            $(".listPreferencesLists").each(function(){
                var child = jQuery(this);
                child.val(child.attr("u"));
            });
            
            $(".educations-delete")
                .attr("title", "Remove this item (删除)")
                .bind("click", function() {
                    rmline($(this));
                });

            $(".educations-add")
                .bind("click", function() {

                    $(".educations-table").append("<div class=\"entity-row\"><div class=\"work\"><span>Graduated (毕业院校):</span><div class=\"entity-notnull-check\"><input name=\"Educations-school\" class='width220' /></div></div><div class=\"work\"><span>Degree (学位):</span><div class=\"entity-selects-check\"><select name=\"Educations-degree\" class=\"customer-degree\"><option value=\"0\">--请选择--</option><option value=\"大专以下\">大专以下</option><option value=\"大专\">大专</option><option value=\"本科\">本科</option><option value=\"硕士\">硕士</option><option value=\"博士\">博士</option><option value=\"MBA\">MBA</option><option value=\"EMBA\">EMBA</option><option value=\"DBA\">DBA</option></select></div></div><div class=\"work\"><span>StartTime (开始时间):</span><span class=\"entity-notnull-check\"><input name=\"edu-starttime\" readonly=\"true\" class=\"datepicker date-cmp date-min2 width220\" /></span></div><div class=\"work\"><span>EndTime (结束时间):</span><span class=\"entity-notnull-check\"><input name=\"edu-endtime\" readonly=\"true\" class=\"datepicker date-cmp date-max2 width220\" /></span></div><a class=\"educations-delete\" href=\"javascript:void(0)\"></a><div class=\"hr\"></div></div>");
                        $(".educations-delete").last()
                            .attr("title", "Remove this item (删除)")
                            .bind("click", function() {
                                rmline($(this));
                            });
                            
                    InputUIShow();
                    $(".datepicker").datepicker({
                        changeYear: true,
                        changeMonth: true,
                        yearRange: 'c-40:c+10',
                        showOn: "button",
                        buttonImage: "../../images/calendar.gif",
                        buttonImageOnly: true,
                        buttonText: 'Open Calendar (打开日历)'
                    }).attr("readonly", "true");
                    
                    $(".date-min2").bind("change", function() {
                            var mintime = $(this).val();
                            var maxtime = $(this).parent().parent().next().children().first().next().children().first().val();
                            if(maxtime!=""&&mintime.valueOf() > maxtime.valueOf())
                            {
                                alert("[Start Time]: could not be later than [End Time]:");
                                $(this).val("");
                            }
                            
                        });
                        $(".date-max2").bind("change", function() {
                            var mintime = $(this).parent().parent().prev().children().first().next().children().first().val();
                            var maxtime = $(this).val();
                            if(mintime!=""&&mintime.valueOf() > maxtime.valueOf())
                            {
                                alert("[End Time]: could not be earlier than [Start Time]:");
                                $(this).val("");
                            }
                            
                        });  

                });

            $(".familyinfo-delete")
                .attr("title", "Remove this item (删除)")
                .bind("click", function() {
                    rmline($(this));
                });

            $(".familyinfo-add")
                .bind("click", function() {

                    $(".familyinfo-table").append("<div class='entity-row'> <div class='rel'> <span>Name (姓名):</span> <div class=\"entity-notnull-check\"><input name='FamilyInfo-name' class='width165' /></div></div> <div class='rel'> <span>Relationship (关系):</span> <div class=\"entity-notnull-check\"><input name='FamilyInfo-relationship' class='width165'/></div></div> <div class='rel'> <span>Work Place (工作地点):</span> <input name='FamilyInfo-workPlace' class='width165' /></div> <a class='familyinfo-delete' href='javascript:void(0)'></a><div class='hr'></div></div>");
                            $(".familyinfo-delete").last()
                                .attr("title", "Remove this item (删除)")
                                .bind("click", function() {
                                    rmline($(this));
                                });
                    InputUIShow();
                });

            $(".workexperience-delete")
                .attr("title", "Remove this item (删除)")
                .bind("click", function() {
                    rmline($(this));
                });

            $(".workexperience-add")
                .bind("click", function() {

            $(".workexperience-table").append("<div class='entity-row'> <div class='work'><span>Company Name (公司名称):</span><div class=\"entity-notnull-check\"> <input name='WorkExperience-name' class='width220' /></div></div> <div class='work'><span>Title (职位):</span> <input name='WorkExperience-title' class='width220' /></div>  <div class='work'><span>StartTime (开始时间):</span><span class=\"entity-notnull-check\"> <input name='WorkExperience-starttime' class='datepicker date-cmp date-min2 width220' /></span></div>  <div class='work'><span>EndTime (结束时间):</span><span class=\"entity-notnull-check\"><input name='WorkExperience-endtime' class='datepicker date-cmp date-max2 width220' /></span></div>  <a class='workexperience-delete' href='javascript:void(0)'></a><div class='hr'></div> </div>");
                    $(".workexperience-delete").last()
                        .attr("title", "Remove this item (删除)")
                        .bind("click", function() {
                            rmline($(this));
                        });
                        InputUIShow();
                        $(".datepicker").datepicker({
                            changeYear: true,
                            changeMonth: true,
                            yearRange: 'c-40:c+10',
                            showOn: "button",
                            buttonImage: "../../images/calendar.gif",
                            buttonImageOnly: true,
                            buttonText: 'Open Calendar (打开日历)'
                        }).attr("readonly", "true");
                        
                        $(".date-min2").bind("change", function() {
                            var mintime = $(this).val();
                            var maxtime = $(this).parent().parent().next().children().first().next().children().first().val();
                            if(maxtime!=""&&mintime.valueOf() > maxtime.valueOf())
                            {
                                alert("[Start Time]: could not be later than [End Time]:");
                                $(this).val("");
                            }
                            
                        });
                        $(".date-max2").bind("change", function() {
                            var mintime = $(this).parent().parent().prev().children().first().next().children().first().val();
                            var maxtime = $(this).val();
                            if(mintime!=""&&mintime.valueOf() > maxtime.valueOf())
                            {
                                alert("[End Time]: could not be earlier than [Start Time]:");
                                $(this).val("");
                            }
                            
                        });  


            });
            
            $(".preference-delete")
                .attr("title", "Remove this item (删除)")
                .bind("click", function() {
                    rmline($(this));
                });

            $(".preference-add")
                .bind("click", function() {
                    $(".preference-table").append("<div class=\"entity-row\"><div style=\"float:left\"><span style=\"display:none\">Preferences (喜好)</span></div> <div class=\"fl container-1 entity-selects-check\">&nbsp;&nbsp;<select class='listPreferencesLists1' name=\"preferenceList\" >" + List + "</select></div><div class=\"fl container-2\">&nbsp;&nbsp;<select name=\"preferenceValue\" class='listPreferencesValues1'></select></div><div class=\"fl container-3\">&nbsp;&nbsp;<select name=\"preferenceLevel\" class='listPreferencesLevels1'></select></div><a class=\"entity-delete preference-delete\" href=\"javascript:void(0)\"></a><div class='hr'></div></div>");
                    $(".preference-delete").last()
                        .attr("title", "Remove this item (删除)")
                        .bind("click", function() {
                            rmline($(this));
                        });
                    preferenceBinding($(".container-2 select").last(), $(".container-3 select").last());
                    InputUIShow();
                });
        
             $("#add-department").bind("click",function (){
                    $(".create-department").show();
             })
             $(".button-department").bind("click",function (){
                var value1=$(".text-department").val();
                if(value1!="")
                {
                    var log="0";
                    $(".option-department").each(function(){
                        var child = jQuery(this);
                        if(log=="0" && child.text()==value1)
                        {
                            $("select#edSelect").val(child.val());
                            log="1";
                            
                        }
                    });
                    if(log=="0")
                    {
                        //$("select#edSelect option:last").remove(); 
                        $("select#edSelect").append("<option value="+value1+" selected>"+value1+"</option>");
                        //$("select#edSelect").append("<option value=\"-1\">--其它--</option>");
                        }
                }
                $(".create-department").hide();
                $(".text-department").val("");
             })
             
             $(".select-company").bind("change",function (){
                var value1=$(".select-company").val();
                var params = '{companyID:"' + value1 + '"}';
                if(value1!="")
                {
                    $.ajax({
                    type: "POST",
                    url: "CustomerInfo.aspx/GetAreaByCompanyID",
                    data: params,
                    dataType: "json",
                    contentType: "application/json; charset=utf-8",
                    success: function(result) {
                        var res = result.d.split(';');
                        $("#txt_Area").text(res[0]);
                        $("#txt_Country").text(res[1]);
                    },
                    error: function(xhr, msg, e) {  
                        $("#txt_Area").text("");
                        $("#txt_Country").text("");
                    }
                });
                }
             });
             
             
             
             
             
             
             $(".training-delete")
                    .attr("title", "Remove this item")
                    .bind("click", function() {
                        rmline($(this));
                        });
             
             $("#trainingYes").bind("click",function(){
                $(".training_area").show();
             });
             
             $("#trainingNo").bind("click",function(){
                $(".training_area").hide();
                $(".training_area div").empty();
             });
             
             $("#training_add").bind("click",function(){
                $(".training_repeat").append("<div class=\"training_row\"><div class=\"train\"><div style=\"display: inline;\">Type(培训类型):</div> <div style=\"display: inline;\" class=\"entity-selects-check\"><select class=\"train_select\" name=\"trainselect\"><option value=\"0\">--请选择--</option><option value=\"MBA\">MBA</option><option value=\"DBA\">DBA</option><option value=\"A培\">A培</option><option value=\"-1\">其它</option></select></div> <span class=\"other_training\" style=\"display: none;\"><input class=\"other_training_text\" type=\"text\" /><input class=\"other_training_sure btn\" type=\"button\" value=\"确定\" /></span><br /> <div style=\"display: inline;\">Date(培训时间):</div> <div class=\"entity-notnull-check\" style=\"display: inline;\"><input name=\"TrainingDate\" type=\"text\" readonly=\"true\" class=\"datepicker\" /></div></div><a class='training-delete' href='javascript:void(0)'></a><div class='hr'></div></div>");
                $(".training-delete").last()
                    .attr("title", "Remove this item")
                    .bind("click", function() {
                        rmline($(this));
                        });
                InputUIShow();
                $(".training_repeat").find(".datepicker").last().datepicker({
                changeYear: true,
                changeMonth: true,
                yearRange: 'c-40:c+10',
                changeYear: true,
                showOn: "button",
                buttonImage: "../../images/calendar.gif",
                buttonImageOnly: true,
                buttonText: 'Open Calendar (打开日历)'
                    }).attr("readonly", "true");
                $(".train_select").bind("change",function(){
                if($(this).val()=="-1")
                {
                    $(this).parent().next().show();
                }
                else
                    $(this).parent().next().hide();
                });
                $(".other_training_sure").bind("click",function(){
                if($(this).prev().val()!="")
                    $(this).parent().prev().children().first().append("<option Value="+$(this).prev().val()+" selected>"+$(this).prev().val()+"</option>");
                $(this).parent().hide();
                });
             });
             
             $(".train_select").bind("change",function(){
                if($(this).val()=="-1")
                {
                    $(this).parent().next().show();
                }
                else
                    $(this).parent().next().hide();
             });
             
             $(".other_training_sure").bind("click",function(){
                if($(this).prev().val()!="")
                    $(this).parent().prev().children().first().append("<option Value="+$(this).prev().val()+" selected>"+$(this).prev().val()+"</option>");
                $(this).parent().hide();
             });
             
             
             $(".value-training").appendTo(".show-training");
             $(".training_row").appendTo(".training_repeat");
             $(".savetodraft").appendTo(".btn-action");
             }
             $(".entity-add").hide();
        });
    </script>

    <!-- validation script -->

    <script type="text/javascript">
        $(function() {
            $("#txt_Area").text(function() {
                var value1 = $(".select-company").val();
                var value2 = $("#CompanyLabel").val();
                if ($("#CompanyLabel").length > 0)
                    value1 = value2;
                var params = '{companyID:"' + value1 + '"}';
                if (value1 != "") {
                    $.ajax({
                        type: "POST",
                        url: "CustomerInfo.aspx/GetAreaByCompanyID",
                        data: params,
                        dataType: "json",
                        contentType: "application/json; charset=utf-8",
                        success: function(result) {
                            var res = result.d.split(';');
                            $("#txt_Area").text(res[0]);
                            $("#txt_Country").text(res[1]);
                        },
                        error: function(xhr, msg, e) {
                            $("#txt_Area").text("");
                            $("#txt_Country").text("");
                        }
                    });
                }
            });
            if ($("#edSelect").length > 0) {
                $(".datepicker").datepicker({
                    changeYear: true,
                    changeMonth: true,
                    yearRange: 'c-40:c+10',
                    changeYear: true,
                    showOn: "button",
                    buttonImage: "../../images/calendar.gif",
                    buttonImageOnly: true,
                    buttonText: 'Open Calendar (打开日历)'
                }).attr("readonly", "true");

                $(".date-min2").bind("change", function() {
                    var mintime = $(this).val();
                    var maxtime = $(this).parent().parent().next().children().first().next().children().first().val();
                    if (maxtime != "" && mintime.valueOf() > maxtime.valueOf()) {
                        alert("[Start Time]: could not be later than [End Time]:");
                        $(this).val("");
                    }

                });
                $(".date-max2").bind("change", function() {
                    var mintime = $(this).parent().parent().prev().children().first().next().children().first().val();
                    var maxtime = $(this).val();
                    if (mintime != "" && mintime.valueOf() > maxtime.valueOf()) {
                        alert("[End Time]: could not be earlier than [Start Time]:");
                        $(this).val("");
                    }

                });

            }
        });
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <div class="mainbox">
        <div class="sitemapbox">
            <div id="info" class="sitemap">
                &nbsp;&raquo;&nbsp;Home&nbsp;&raquo;&nbsp;Customer
            </div>
        </div>
        <table cellspacing="0" cellpadding="0">
            <tr>
                <td>
                    <!--tab区域-->
                    <div class="tabbox purplebg_dark">
                        <ul class="tabpos">
                            <li><span class="tab_active">
                                <%=Resources.PageTitles.CustomerManagement%></span></li>
                        </ul>
                    </div>
                    <div class="formbox">
                        <span class=" float_lft">
                            <div class="formbox_float_lft">
                                <asp:Button ID="btnAdd" runat="server" CssClass="entity-add" />
                            </div>
                            <div class="formbox_float_rgt" style="display: none">
                                <asp:TextBox ID="SearchText" runat="server" CssClass="txtbox width140 entity-search-text"
                                    ToolTip="Customer Name"></asp:TextBox>
                                <asp:Button ID="Searchbtn" runat="server" CssClass="entity-search" />
                                <asp:Button ID="Cleanbtn" runat="server" CssClass="entity-clear" />
                            </div>
                        </span>
                    </div>
                </td>
            </tr>
        </table>
        <table width="100%" id="Table1" cellspacing="0" cellpadding="0" border="0">
            <tbody>
                <tr>
                    <td>
                        <asp:GridView ID="GVCustomer" runat="server" AutoGenerateColumns="False" DataKeyNames="CustomerID"
                            DataSourceID="edsCustomer" AllowPaging="True" AllowSorting="True" CssClass="tablestyle">
                            <RowStyle CssClass="tbody" />
                            <HeaderStyle CssClass="thead" ForeColor="#ffffff" />
                            <Columns>
                                <asp:BoundField DataField="Name" HeaderText="Customer Name<br/>姓名" SortExpression="Name"
                                    HtmlEncode="false" ItemStyle-Width="21%" />
                                <asp:TemplateField HeaderText="Company<br/>公司名称" SortExpression="Company.CompanyID">
                                    <ItemTemplate>
                                        <asp:Label ID="Company" runat="server" Text='<%#Eval("Company.Name")%>' />
                                    </ItemTemplate>
                                    <ItemStyle Width="26%" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Department<br/>所属部门" SortExpression="CustomerDepartment.DepartmentID">
                                    <ItemTemplate>
                                        <asp:Label ID="Department" runat="server" Text='<%#Eval("CustomerDepartment.Name")%>' />
                                    </ItemTemplate>
                                    <ItemStyle Width="16%" />
                                </asp:TemplateField>
                                <asp:BoundField DataField="Title" HeaderText="Title<br/>职位" SortExpression="Title"
                                    HtmlEncode="false" ItemStyle-Width="16%" />
                                <asp:TemplateField HeaderText="Editor<br/>编辑人" SortExpression="LastModifyBy.EmployeeNo">
                                    <ItemTemplate>
                                        <asp:Label ID="LastModifyBy" runat="server" Text='<%#Eval("LastModifyBy.NameEN")%>' />
                                    </ItemTemplate>
                                    <ItemStyle Width="14%" />
                                </asp:TemplateField>
                                <asp:ActionField HeaderText="Action<br />操作" HeaderStyle-CssClass="entity-action"
                                    ShowDisableButton="true" ShowModifyButton="true" ShowViewButton="true" ItemStyle-Width="7%" />
                            </Columns>
                            <PagerTemplate>
                                <cc:Pager ID="Pager1" runat="server" />
                            </PagerTemplate>
                        </asp:GridView>
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:DetailsView ID="DVCustomer" runat="server" AutoGenerateRows="False" DataKeyNames="CustomerID"
                            DataSourceID="edsCustomer" DefaultMode="Edit" Visible="False" CssClass="tablestyle2"
                            Width="940">
                            <HeaderStyle CssClass="tablestyle2_Title"></HeaderStyle>
                            <HeaderTemplate>
                                <%=Resources.PageTitles.CustomerManagement%>
                            </HeaderTemplate>
                            <FieldHeaderStyle CssClass="tablestyle2_tdTitle" Width="200" />
                            <Fields>
                                <asp:TemplateField ShowHeader="false">
                                    <ItemStyle CssClass="Customer_Block" />
                                    <ItemTemplate>
                                        &nbsp;1.Basic Information (客户基本信息)
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:CustomizeTemplateField ItemStyle-CssClass="entity-notnull-check entity-length-check widthInfo"
                                    HeaderText="Customer Name (姓名)" MaxLength="50">
                                    <ItemTemplate>
                                        <label>
                                            <%#Eval("Name") %></label>
                                    </ItemTemplate>
                                    <InsertItemTemplate>
                                        <input type="text" name="customer-name" class="check-name"></input>
                                        <font id="name_identity" style="color: Red;"></font>
                                    </InsertItemTemplate>
                                    <EditItemTemplate>
                                        <input type="text" name="customer-name" class="check-name" value='<%#Eval("Name") %>' /><label
                                            id="name_identity" style="color: Red;"></label>
                                    </EditItemTemplate>
                                </asp:CustomizeTemplateField>
                                <asp:TemplateField>
                                    <ItemTemplate>
                                        <asp:Label ID="Gender" runat="server" Text='<%# GetGender(Eval("Gender"))%>' />
                                    </ItemTemplate>
                                    <EditItemTemplate>
                                        <select name='Genderselect' class="entity-gender" u="<%#CheckGender(Eval("Gender"))%>">
                                            <option value="0">--请选择--</option>
                                            <option value="1">Male (男)</option>
                                            <option value="2">Female (女)</option>
                                        </select>
                                        <%--<asp:RadioButton GroupName="12" ID="RadioButton1" runat="server" Checked=<%#CheckGender(Eval("Gender"),"Male")%> />Male
                                        <asp:RadioButton GroupName="12" ID="RadioButton2" runat="server" Checked=<%#CheckGender(Eval("Gender"),"Female") %> />Female--%>
                                    </EditItemTemplate>
                                    <HeaderTemplate>
                                        Gender (性别)
                                    </HeaderTemplate>
                                    <InsertItemTemplate>
                                        <select name='Genderselect' class="entity-gender" u="<%#CheckGender(Eval("Gender"))%>">
                                            <option value="0">--请选择--</option>
                                            <option value="1">Male (男)</option>
                                            <option value="2">Female (女)</option>
                                        </select>
                                    </InsertItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Birthday (生日)">
                                    <ItemTemplate>
                                        <%#Eval("Birthday", "{0:MM/dd/yyyy}")%>
                                    </ItemTemplate>
                                    <EditItemTemplate>
                                        <input type="text" name="BirthdayText" id="BirthdayText" runat="server" readonly="true"
                                            value='<%#Bind("Birthday", "{0:MM/dd/yyyy}") %>' class="datepicker widthInfo" />
                                    </EditItemTemplate>
                                    <InsertItemTemplate>
                                        <input type="text" name="BirthdayText" id="BirthdayText" runat="server" readonly="true"
                                            value='<%#Bind("Birthday", "{0:MM/dd/yyyy}") %>' class="datepicker widthInfo" />
                                    </InsertItemTemplate>
                                </asp:TemplateField>
                                <asp:CustomizeBoundField DataField="Title" HeaderText="Title (职位)" SortExpression="Title"
                                    ItemStyle-CssClass="entity-length-check widthInfo" MaxLength="100" />
                                <%--公司--%>
                                <asp:TemplateField ItemStyle-CssClass="entity-selects-check" HeaderText="Company Name (公司)">
                                    <ItemTemplate>
                                        <asp:Label ID="Label1" ToolTip='<%#Eval("Company.CompanyID")%>' runat="server" Text='<%#Eval("Company.Name")%>' />
                                        <input type="text" id="CompanyLabel" value='<%#Eval("Company.CompanyID")%>' style="display: none" />
                                    </ItemTemplate>
                                    <EditItemTemplate>
                                        <select id="company-list-a" name="Companyselect" class="entity-company select-company">
                                            <option value='<%#EvalX("Company.CompanyID") %>'></option>
                                        </select>
                                        <a href="javascript:void(0)" class="btn" id="pickcompany" title="<%#Resources.GlobalButton.AdvancedTips %>">
                                            <%#Resources.GlobalButton.Advanced %></a><a href="javascript:void(0)" class="btn"
                                                id="newcompany" title="<%#Resources.GlobalButton.AddCompanyTips %>">Add Company</a>
                                    </EditItemTemplate>
                                    <InsertItemTemplate>
                                        <select id="company-list-a" name="Companyselect" class="insert-company select-company">
                                            <option value='<%#Request.QueryString["companyid"] %>'></option>
                                        </select>
                                        <a href="javascript:void(0)" class="btn" id="pickcompany" title="<%#Resources.GlobalButton.AdvancedTips %>">
                                            <%#Resources.GlobalButton.Advanced %></a><a href="javascript:void(0)" class="btn"
                                                id="newcompany" title="<%#Resources.GlobalButton.AddCompanyTips %>">Add Company</a>
                                    </InsertItemTemplate>
                                </asp:TemplateField>
                                <%--Country--%>
                                <asp:TemplateField HeaderText="Region/Country<br />(区域)/(国家)">
                                    <ItemTemplate>
                                        <ul>
                                            <li style="width: 700px; float: left;"><span style="width: 90px; float: left; font-style: italic;">
                                                Region(区域):</span>
                                                <label id="txt_Area" style="border: 0px; padding-top: 5px; color: Black;">
                                                </label>
                                            </li>
                                            <li style="width: 700px; float: left;"><span style="width: 90px; float: left; font-style: italic;">
                                                Country(国家):</span>
                                                <label id="txt_Country" style="border: 0px; padding-top: 5px; color: Black;">
                                                </label>
                                            </li>
                                        </ul>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <%--部门--%>
                                <asp:TemplateField ItemStyle-CssClass="entity-selects-nullable-check">
                                    <ItemTemplate>
                                        <asp:Label ID="Department" runat="server" Text='<%#Eval("CustomerDepartment.Name")%>' />
                                    </ItemTemplate>
                                    <EditItemTemplate>
                                        <select id="edSelect" name="Departmentselect" class="entity-department select-department">
                                            <option value='<%#EvalX("CustomerDepartment.DepartmentID") %>'></option>
                                        </select>
                                        <a href="javascript:void(0)" class="btn" id="pick-department" title="<%#Resources.GlobalButton.AdvancedTips %>">
                                            <%#Resources.GlobalButton.Advanced %></a> <a href="javascript:void(0)" class="btn"
                                                id="add-department" title="<%#Resources.GlobalButton.AddDepartmentTips %>">Add Department</a>
                                        <div class="create-department" style="display: none">
                                            <input type="text" class="text-department" />
                                            <a class="button-department btn" title="Add (添加)">Add</a>
                                        </div>
                                    </EditItemTemplate>
                                    <HeaderTemplate>
                                        Department (部门)
                                    </HeaderTemplate>
                                    <InsertItemTemplate>
                                        <select id="edSelect" name="Departmentselect" class="select-department department-select">
                                            <option value="0">--请选择--</option>
                                        </select>
                                        <a href="javascript:void(0)" class="btn" id="pick-department" title="<%#Resources.GlobalButton.AdvancedTips %>">
                                            <%#Resources.GlobalButton.Advanced %></a> <a href="javascript:void(0)" class="btn"
                                                id="add-department" title="<%#Resources.GlobalButton.AddDepartmentTips %>">Add Department</a>
                                        <div class="create-department" style="display: none">
                                            <input type="text" class="text-department" />
                                            <a class="button-department btn" title="Add (添加)">Add</a>
                                        </div>
                                    </InsertItemTemplate>
                                </asp:TemplateField>
                                <asp:CustomizeBoundField DataField="CellPhone" HeaderText="Cell Phone (手机号码)" ItemStyle-CssClass="entity-length-check widthInfo"
                                    MaxLength="20" />
                                <asp:CustomizeBoundField DataField="Email" HeaderText="Email (邮箱)" ItemStyle-CssClass="entity-email-check entity-length-check widthInfo"
                                    MaxLength="50" />
                                <asp:CustomizeBoundField DataField="Nationality" HeaderText="Nationality (国籍)" ItemStyle-CssClass="entity-length-check widthInfo"
                                    MaxLength="50" AccessibleHeaderText="Nationality" />
                                <%--客户定义--%>
                                <asp:TemplateField HeaderText="Customer Definition (客户定义)" AccessibleHeaderText="Definition">
                                    <ItemTemplate>
                                        <%#GetDefinitionText(EvalX("Definition"))%>
                                    </ItemTemplate>
                                    <EditItemTemplate>
                                        <select name="Definitionselect" class="entity-definition" u="<%#EvalX("Definition.DefID") %>">
                                            <option value="">--请选择--</option>
                                            <asp:Repeater ID="Repeater5" runat="server" DataSourceID="edsDefinition">
                                                <ItemTemplate>
                                                    <option value="<%#Eval("DefID") %>">
                                                        <%#Eval("Name") %></option>
                                                </ItemTemplate>
                                            </asp:Repeater>
                                        </select>
                                    </EditItemTemplate>
                                    <InsertItemTemplate>
                                        <select name="Definitionselect">
                                            <option value="">--请选择--</option>
                                            <asp:Repeater ID="Repeater2" runat="server" DataSourceID="edsDefinition">
                                                <ItemTemplate>
                                                    <option value="<%#Eval("DefID") %>">
                                                        <%#Eval("Name") %></option>
                                                </ItemTemplate>
                                            </asp:Repeater>
                                        </select>
                                    </InsertItemTemplate>
                                </asp:TemplateField>
                                <%--A培--%>
                                <%--<asp:TemplateField HeaderText="是否参加过公司组织的DBA,MBA,A培" Visible="false">
                                    <ItemTemplate>
                                        <asp:Repeater ID="Repeater5" runat="server" DataSource='<%#GetTrainingByCustomerID((int)Eval("CustomerID")) %>'>
                                            <HeaderTemplate>
                                                <div class="show-training">
                                                </div>
                                            </HeaderTemplate>
                                            <FooterTemplate>
                                                <div class="value-training">
                                                    <%#(this.DVCustomer.FindControl("Repeater5") as Repeater).Items.Count == 0 ? "否" : "是"%><br />
                                                </div>
                                            </FooterTemplate>
                                            <ItemTemplate>
                                                <div style="display: inline;">
                                                    Type(培训类型):</div>
                                                <%#Eval("Name") %>&nbsp;
                                                <div style="display: inline;">
                                                    Date(培训时间):</div>
                                                <%#Eval("Date", "{0:MM/dd/yyyy}")%><br />
                                            </ItemTemplate>
                                        </asp:Repeater>
                                    </ItemTemplate>
                                    <InsertItemTemplate>
                                        <div>
                                            <input type="radio" id="trainingYes" name="TrainingCheck" />是
                                            <input type="radio" id="trainingNo" name="TrainingCheck" checked />否
                                        </div>
                                        <div class="training_area" style="display: none">
                                            <div class="training_repeat">
                                            </div>
                                            <a href="javascript:void(0)" id="training_add" class="btn" title="<%#Resources.GlobalButton.AddTips %>">
                                                <%#Resources.GlobalButton.Add %></a>
                                        </div>
                                    </InsertItemTemplate>
                                    <EditItemTemplate>
                                        <asp:Repeater ID="rp1" runat="server" DataSource='<%#GetTrainingByCustomerID((int)Eval("CustomerID")) %>'>
                                            <HeaderTemplate>
                                                <div class="show-training">
                                                </div>
                                            </HeaderTemplate>
                                            <ItemTemplate>
                                                <div class="training_row">
                                                    <div class="train">
                                                        <div style="display: inline;">
                                                            Type(培训类型):</div>
                                                        <div style="display: inline;" class="entity-selects-check ">
                                                            <select class="train_select train_select_band" name="trainselect" u="<%#Eval("Name") %>">
                                                                <option value="0">--请选择--</option>
                                                                <option value="MBA">MBA</option>
                                                                <option value="DBA">DBA</option>
                                                                <option value="A培">A培</option>
                                                                <option value="-1">其它</option>
                                                            </select></div>
                                                        <span class="other_training" style="display: none;">
                                                            <input class="other_training_text" type="text" />
                                                            <input class="other_training_sure" type="button" value="确定" />
                                                        </span>
                                                        <br />
                                                        <div style="display: inline;">
                                                            Date(培训时间):</div>
                                                        <div class="entity-notnull-check" style="display: inline;">
                                                            <input name="TrainingDate" type="text" readonly="true" class="datepicker" value='<%#Eval("Date", "{0:MM/dd/yyyy}")%>' />
                                                        </div>
                                                    </div>
                                                    <a class='training-delete' href='javascript:void(0)'></a>
                                                    <div class='hr'>
                                                    </div>
                                                </div>
                                            </ItemTemplate>
                                            <FooterTemplate>
                                                <input type="radio" id="trainingYes" name="TrainingCheck" <%#(this.DVCustomer.FindControl("rp1")as Repeater).Items.Count==0?"":"checked"%> />是
                                                <input type="radio" id="trainingNo" name="TrainingCheck" <%#(this.DVCustomer.FindControl("rp1")as Repeater).Items.Count==0?"checked":""%> />否
                                                <div class="training_area" <%#(this.DVCustomer.FindControl("rp1") as Repeater).Items.Count==0?"style=\"display:none\"":""%>>
                                                    <div class="training_repeat">
                                                    </div>
                                                    <a href="javascript:void(0)" id="training_add" class="btn" title="<%#Resources.GlobalButton.AddTips %>">
                                                        <%#Resources.GlobalButton.Add %></a>
                                                </div>
                                            </FooterTemplate>
                                        </asp:Repeater>
                                    </EditItemTemplate>
                                </asp:TemplateField>--%>
                                <%--客户级别--%>
                                <asp:TemplateField>
                                    <ItemTemplate>
                                        <%#(int)Eval("Level")==0?"":"Level"%>&nbsp
                                        <asp:Label ID="Level" runat="server" Text='<%#(int)Eval("Level")==0?"":Eval("Level")%>' />
                                        <div class="padding_top5">
                                            <div class="hr">
                                            </div>
                                            <ul>
                                                <li>Level Description(级别说明)：</li>
                                                <li><span>
                                                    <div class="padding_lft25">
                                                        <%=Resources.PageTitles.LevelDescriptionC1%>
                                                        <%=Resources.PageTitles.LevelDescriptionE1%>
                                                        <br />
                                                        <%=Resources.PageTitles.LevelDescriptionC2%>
                                                        <%=Resources.PageTitles.LevelDescriptionE2%>
                                                        <br />
                                                        <%=Resources.PageTitles.LevelDescriptionC3%>
                                                        <%=Resources.PageTitles.LevelDescriptionE3%>
                                                        <br />
                                                        <%=Resources.PageTitles.LevelDescriptionC4%>
                                                        <%=Resources.PageTitles.LevelDescriptionE4%>
                                                    </div>
                                                </span></li>
                                            </ul>
                                        </div>
                                    </ItemTemplate>
                                    <EditItemTemplate>
                                        <select name="Level" class="entity-level" u="<%#Eval("Level") %>">
                                            <option value="0">--请选择--</option>
                                            <option value="1">Level1</option>
                                            <option value="2">Level2</option>
                                            <option value="3">Level3</option>
                                            <option value="4">Level4</option>
                                        </select>
                                        <div class="padding_top5">
                                            <div class="hr">
                                            </div>
                                            <ul>
                                                <li>Level Description(级别说明)：</li>
                                                <li><span>
                                                    <div class="padding_lft25">
                                                        <%=Resources.PageTitles.LevelDescriptionC1%>
                                                        <%=Resources.PageTitles.LevelDescriptionE1%>
                                                        <br />
                                                        <%=Resources.PageTitles.LevelDescriptionC2%>
                                                        <%=Resources.PageTitles.LevelDescriptionE2%>
                                                        <br />
                                                        <%=Resources.PageTitles.LevelDescriptionC3%>
                                                        <%=Resources.PageTitles.LevelDescriptionE3%>
                                                        <br />
                                                        <%=Resources.PageTitles.LevelDescriptionC4%>
                                                        <%=Resources.PageTitles.LevelDescriptionE4%>
                                                    </div>
                                                </span></li>
                                            </ul>
                                        </div>
                                    </EditItemTemplate>
                                    <HeaderTemplate>
                                        Level (级别)
                                    </HeaderTemplate>
                                    <InsertItemTemplate>
                                        <select name="Level">
                                            <option value="0">--请选择--</option>
                                            <option value="1">Level1</option>
                                            <option value="2">Level2</option>
                                            <option value="3">Level3</option>
                                            <option value="4">Level4</option>
                                        </select>
                                        <div class="padding_top5">
                                            <div class="hr">
                                            </div>
                                            <ul>
                                                <li>Level Description(级别说明)：</li>
                                                <li><span>
                                                    <div class="padding_lft25">
                                                        <%=Resources.PageTitles.LevelDescriptionC1%>
                                                        <%=Resources.PageTitles.LevelDescriptionE1%>
                                                        <br />
                                                        <%=Resources.PageTitles.LevelDescriptionC2%>
                                                        <%=Resources.PageTitles.LevelDescriptionE2%>
                                                        <br />
                                                        <%=Resources.PageTitles.LevelDescriptionC3%>
                                                        <%=Resources.PageTitles.LevelDescriptionE3%>
                                                        <br />
                                                        <%=Resources.PageTitles.LevelDescriptionC4%>
                                                        <%=Resources.PageTitles.LevelDescriptionE4%>
                                                    </div>
                                                </span></li>
                                            </ul>
                                        </div>
                                    </InsertItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField ShowHeader="false">
                                    <ItemStyle CssClass="Customer_Block" />
                                    <ItemTemplate>
                                        &nbsp;2.Other Information (其他信息)
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <%--学历--%>
                                <asp:TemplateField HeaderText="Educations (学历)">
                                    <ItemTemplate>
                                        <asp:Repeater ID="Repeater6" runat="server" DataSource='<%# from t in EvalX("Education") as System.Collections.Generic.IEnumerable<Education>  select t %>'>
                                            <ItemTemplate>
                                                <div class="entity-row">
                                                    <div class="edu">
                                                        <span>Graduated (毕业院校):</span>
                                                        <%#Eval("School")%></div>
                                                    <div class="degree">
                                                        <span>Degree (学位):</span>
                                                        <%#Eval("Degree")%></div>
                                                    <div class="edu width165">
                                                        <span>StartTime (开始时间):</span>
                                                        <%#Eval("StartTime", "{0:MM/dd/yyyy}")%></div>
                                                    <div class="edu width165">
                                                        <span>EndTime (结束时间):</span>
                                                        <%#Eval("EndTime", "{0:MM/dd/yyyy}")%></div>
                                                    <div class="hr">
                                                    </div>
                                                </div>
                                            </ItemTemplate>
                                        </asp:Repeater>
                                    </ItemTemplate>
                                    <EditItemTemplate>
                                        <div class="educations-table">
                                            <asp:Repeater ID="Repeater7" runat="server" DataSource='<%# GetEducations(EvalX("Education")) %>'>
                                                <ItemTemplate>
                                                    <div class="entity-row">
                                                        <div class="work">
                                                            <span>Graduated (毕业院校):</span>
                                                            <div class="entity-notnull-check widthInfo">
                                                                <input name="Educations-school" value="<%#Eval("School") %>" />
                                                            </div>
                                                        </div>
                                                        <div class="work">
                                                            <span>Degree (学位):</span>
                                                            <div class="entity-selects-check">
                                                                <select name="Educations-degree" class="entity-Degree customer-degree width165" u="<%#Eval("Degree") %>">
                                                                    <option value="0">--请选择--</option>
                                                                    <option value="大专以下">大专以下</option>
                                                                    <option value="大专">大专</option>
                                                                    <option value="本科">本科</option>
                                                                    <option value="硕士">硕士</option>
                                                                    <option value="博士">博士</option>
                                                                    <option value="MBA">MBA</option>
                                                                    <option value="EMBA">EMBA</option>
                                                                    <option value="DBA">DBA</option>
                                                                </select></div>
                                                        </div>
                                                        <div class="work">
                                                            <span>StartTime (开始时间):</span><span class="entity-notnull-check">
                                                                <input name="edu-starttime" readonly="true" class="datepicker date-cmp date-min2 width220"
                                                                    value="<%#Eval("StartTime", "{0:MM/dd/yyyy}") %>" /></span></div>
                                                        <div class="work">
                                                            <span>EndTime (结束时间):</span><span class="entity-notnull-check">
                                                                <input name="edu-endtime" readonly="true" class="datepicker date-cmp date-max2 width220"
                                                                    value="<%#Eval("EndTime", "{0:MM/dd/yyyy}") %>" /></span></div>
                                                        <a class="educations-delete" href="javascript:void(0)"></a>
                                                        <div class="hr">
                                                        </div>
                                                    </div>
                                                </ItemTemplate>
                                            </asp:Repeater>
                                        </div>
                                        <br style="clear: both;" />
                                        <a href="javascript:void(0)" class="educations-add btn" title="<%#Resources.GlobalButton.AddEduTips %>">
                                            <%#Resources.GlobalButton.AddEdu %></a>
                                    </EditItemTemplate>
                                    <InsertItemTemplate>
                                        <div class="educations-table">
                                        </div>
                                        <br style="clear: both;" />
                                        <a href="javascript:void(0)" class="educations-add btn" title="<%#Resources.GlobalButton.AddEduTips %>">
                                            <%#Resources.GlobalButton.AddEdu %></a>
                                    </InsertItemTemplate>
                                </asp:TemplateField>
                                <%--家庭成员--%>
                                <asp:TemplateField HeaderText="Relatives (家庭成员)">
                                    <ItemTemplate>
                                        <asp:Repeater ID="Repeater8" runat="server" DataSource='<%# from t in EvalX("FamilyInfo") as System.Collections.Generic.IEnumerable<FamilyInfo>  select t %>'>
                                            <ItemTemplate>
                                                <div class="entity-row">
                                                    <div class="rel">
                                                        <span>Name (姓名):</span>
                                                        <%#Eval("Name")%></div>
                                                    <div class="rel">
                                                        <span>Relationship (关系):</span>
                                                        <%#Eval("Relationship")%></div>
                                                    <div class="rel">
                                                        <span>Work Place (工作地点):</span>
                                                        <%#Eval("WorkPlace")%></div>
                                                    <div class="hr">
                                                    </div>
                                                </div>
                                            </ItemTemplate>
                                        </asp:Repeater>
                                    </ItemTemplate>
                                    <EditItemTemplate>
                                        <div class="familyinfo-table">
                                            <asp:Repeater ID="Repeater9" runat="server" DataSource='<%# GetFamilyinfos(EvalX("FamilyInfo")) %>'>
                                                <ItemTemplate>
                                                    <div class="entity-row">
                                                        <div class="rel">
                                                            <span>Name (姓名):</span>
                                                            <div class="entity-notnull-check">
                                                                <input name="FamilyInfo-name" value="<%#Eval("Name") %>" class="width165" /></div>
                                                        </div>
                                                        <div class="rel">
                                                            <span>Relationship (关系):</span>
                                                            <div class="entity-notnull-check">
                                                                <input name="FamilyInfo-relationship" value="<%#Eval("Relationship") %>" class="width165" /></div>
                                                        </div>
                                                        <div class="rel">
                                                            <span>Work Place (工作地点):</span>
                                                            <input name="FamilyInfo-workPlace" value="<%#Eval("WorkPlace") %>" class="width165" /></div>
                                                        <a class="familyinfo-delete" href="javascript:void(0)"></a>
                                                        <div class="hr">
                                                        </div>
                                                    </div>
                                                </ItemTemplate>
                                            </asp:Repeater>
                                        </div>
                                        <br style="clear: both;" />
                                        <a href="javascript:void(0)" class="familyinfo-add btn" title="<%#Resources.GlobalButton.AddFamilyTips %>">
                                            <%#Resources.GlobalButton.AddFamily %></a>
                                    </EditItemTemplate>
                                    <InsertItemTemplate>
                                        <div class="familyinfo-table">
                                        </div>
                                        <br style="clear: both;" />
                                        <a href="javascript:void(0)" class="familyinfo-add btn" title="<%#Resources.GlobalButton.AddFamilyTips %>">
                                            <%#Resources.GlobalButton.AddFamily %></a>
                                    </InsertItemTemplate>
                                </asp:TemplateField>
                                <%--工作经验--%>
                                <asp:TemplateField HeaderText="Work Experiences (工作经验)" ConvertEmptyStringToNull="true">
                                    <ItemTemplate>
                                        <asp:Repeater ID="Repeater10" runat="server" DataSource='<%# from t in EvalX("WorkExperience") as System.Collections.Generic.IEnumerable<WorkExperience>  select t %>'>
                                            <ItemTemplate>
                                                <div class="entity-row">
                                                    <div class="edu">
                                                        <span>Company Name (公司名称):</span>
                                                        <%#Eval("CompanyName")%></div>
                                                    <div class="edu">
                                                        <span>Title (职位):</span>
                                                        <%#Eval("Title")%></div>
                                                    <div class="edu">
                                                        <span>StartTime (开始时间):</span>
                                                        <%#Eval("StartTime", "{0:MM/dd/yyyy}")%></div>
                                                    <div class="edu">
                                                        <span>EndTime (结束时间):</span>
                                                        <%#Eval("EndTime", "{0:MM/dd/yyyy}")%></div>
                                                    <div class="hr">
                                                    </div>
                                                </div>
                                            </ItemTemplate>
                                        </asp:Repeater>
                                    </ItemTemplate>
                                    <EditItemTemplate>
                                        <div class="workexperience-table">
                                            <asp:Repeater ID="Repeater11" runat="server" DataSource='<%# GetWorkExperiences(EvalX("WorkExperience")) %>'>
                                                <ItemTemplate>
                                                    <div class="entity-row">
                                                        <div class="work">
                                                            <span>Company Name (公司名称):</span>
                                                            <div class="entity-notnull-check">
                                                                <input name="WorkExperience-name" value="<%#Eval("CompanyName") %>" class="width220" /></div>
                                                        </div>
                                                        <div class="work">
                                                            <span>Title (职位):</span>
                                                            <input name="WorkExperience-title" value="<%#Eval("Title") %>" class="width220" /></div>
                                                        <div class="work">
                                                            <span>StartTime (开始时间):</span><span class="entity-notnull-check">
                                                                <input name="WorkExperience-starttime" readonly="true" class="datepicker date-cmp date-min2 width220"
                                                                    value="<%#Eval("StartTime", "{0:MM/dd/yyyy}") %>" /></span></div>
                                                        <div class="work">
                                                            <span>EndTime (结束时间):</span><span class="entity-notnull-check">
                                                                <input name="WorkExperience-endtime" readonly="true" class="datepicker date-cmp date-max2 width220"
                                                                    value="<%#Eval("EndTime", "{0:MM/dd/yyyy}") %>" /></span></div>
                                                        <a class="workexperience-delete" href="javascript:void(0)"></a>
                                                        <div class="hr">
                                                        </div>
                                                    </div>
                                                </ItemTemplate>
                                            </asp:Repeater>
                                        </div>
                                        <br style="clear: both;" />
                                        <a href="javascript:void(0)" class="workexperience-add btn" title="<%#Resources.GlobalButton.AddWorkExTips %>">
                                            <%#Resources.GlobalButton.AddWorkEx %></a>
                                    </EditItemTemplate>
                                    <InsertItemTemplate>
                                        <div class="workexperience-table">
                                        </div>
                                        <br style="clear: both;" />
                                        <a href="javascript:void(0)" class="workexperience-add btn" title="<%#Resources.GlobalButton.AddWorkExTips %>">
                                            <%#Resources.GlobalButton.AddWorkEx %></a>
                                    </InsertItemTemplate>
                                </asp:TemplateField>
                                <%--喜好--%>
                                <asp:TemplateField HeaderText="Preferences (喜好)" AccessibleHeaderText="Preference">
                                    <ItemTemplate>
                                        <asp:Repeater ID="Repeater12" runat="server" DataSource='<%# GetCustomerPreference(EvalX("CustomerPreference")) %>'>
                                            <ItemTemplate>
                                                <div class="entity-row">
                                                    <div class="rel">
                                                        <span>Category (类型):</span>
                                                        <%#Eval("ListName")%></div>
                                                    <div class="rel">
                                                        <span>Content (内容):</span>
                                                        <%#Eval("ValueName")%></div>
                                                    <div class="rel">
                                                        <span>Level (程度):</span>
                                                        <%#Eval("LevelName")%></div>
                                                    <div class="hr">
                                                    </div>
                                                </div>
                                            </ItemTemplate>
                                        </asp:Repeater>
                                    </ItemTemplate>
                                    <EditItemTemplate>
                                        <div class="preference-table">
                                            <asp:Repeater ID="Repeater13" runat="server" DataSource='<%# GetCustomerPreference(EvalX("CustomerPreference")) %>'>
                                                <ItemTemplate>
                                                    <div class="entity-row">
                                                        <div style="float: left">
                                                            <span style="display: none">Preferences (喜好)</span></div>
                                                        <div class="fl container-1 entity-selects-check">
                                                            &nbsp;&nbsp;<select name="preferenceList" class="listPreferencesLists" u="<%#Eval("ListID") %>">
                                                                <option value="0">--请选择--</option>
                                                                <asp:Repeater ID="Repeater3" runat="server" DataSourceID="edsPreferencesLists">
                                                                    <ItemTemplate>
                                                                        <option value='<%#Eval("ListID") %>'>
                                                                            <%#Eval("Name")%></option>
                                                                    </ItemTemplate>
                                                                </asp:Repeater>
                                                            </select>
                                                        </div>
                                                        <div class="fl container-2">
                                                            &nbsp;&nbsp;<select name="preferenceValue" class="listPreferencesValues" u="<%#Eval("ValueID") %>">
                                                                <option value="<%#Eval("ValueID") %>">
                                                                    <%#Eval("ValueName")%></option>
                                                            </select>
                                                        </div>
                                                        <div class="fl container-3">
                                                            &nbsp;&nbsp;<select name="preferenceLevel" class="listPreferencesLevels" u="<%#Eval("LevelID") %>">
                                                                <option value="<%#Eval("LevelID") %>">
                                                                    <%#Eval("LevelName") %></option>
                                                            </select>
                                                        </div>
                                                        <a class="entity-delete preference-delete" href="javascript:void(0)"></a>
                                                        <div class="hr">
                                                        </div>
                                                    </div>
                                                </ItemTemplate>
                                            </asp:Repeater>
                                        </div>
                                        <br style="clear: both;" />
                                        <a href="javascript:void(0)" class="preference-add btn" title="<%#Resources.GlobalButton.AddpreferenceTips %>">
                                            <%#Resources.GlobalButton.Addpreference %></a>
                                    </EditItemTemplate>
                                    <InsertItemTemplate>
                                        <div class="preference-table">
                                        </div>
                                        <br style="clear: both;" />
                                        <a href="javascript:void(0)" class="preference-add btn" title="<%#Resources.GlobalButton.AddpreferenceTips %>">
                                            <%#Resources.GlobalButton.Addpreference %></a>
                                    </InsertItemTemplate>
                                </asp:TemplateField>
                                <asp:CustomizeBoundField DataField="Address" HeaderText="Address (家庭住址)" ItemStyle-CssClass="entity-length-check"
                                    MaxLength="200" ControlStyle-Width="500" />
                                <asp:CustomizeBoundField DataField="Description" HeaderText="Comment (备注)" ItemStyle-CssClass="entity-length-check"
                                    MaxLength="50" ControlStyle-Width="500" ControlStyle-Height="80" />
                                <asp:TemplateField HeaderText="Editor (编辑人)" AccessibleHeaderText="LastModifyBy">
                                    <ItemTemplate>
                                        <asp:Label ID="Label2" runat="server" Text='<%#Eval("LastModifyBy.NameEN")%>' />
                                    </ItemTemplate>
                                    <EditItemTemplate>
                                        <input type="submit" name="DVCustomer:_ctl7" value="Save To Draft" class="btn savetodraft"
                                            title="Save To Draft (保存为草稿)" onclick="javascript:$('#IsDraft').val('1')" />
                                        <asp:Label ID="Label3" runat="server" Text='<%# GetUser()%>' />
                                    </EditItemTemplate>
                                    <InsertItemTemplate>
                                        <input type="submit" name="DVCustomer:_ctl7" value="Save To Draft" class="btn savetodraft"
                                            title="Save To Draft (保存为草稿)" onclick="javascript:$('#IsDraft').val('1')" />
                                        <asp:Label ID="Label4" runat="server" Text='<%# GetUser()%>' />
                                    </InsertItemTemplate>
                                </asp:TemplateField>
                                <asp:ActionField ShowEditButton="true" ShowInsertButton="true" ShowInsertMoreButton="true"
                                    ShowCloseButton="true" ItemStyle-CssClass="btn-action" />
                            </Fields>
                        </asp:DetailsView>
                        &nbsp;
                    </td>
                </tr>
            </tbody>
        </table>
        <input type="text" id="IsDraft" name="IsDraft" style="display: none" />
    </div>
    <%--以下是数据源--%>
    <asp:EntityDataSource ID="edsCustomer" runat="server" ConnectionString="name=CCEntities"
        DefaultContainerName="CCEntities" EnableDelete="True" EnableInsert="True" EnableUpdate="True"
        EntitySetName="Customers" Where="!it.Disabled" Include="LastModifyBy,Company,CustomerDepartment,Definition,Education,FamilyInfo,WorkExperience,CustomerPreference"
        OnInserted="edsCustomer_Inserted" OnUpdated="edsCustomer_Updated">
    </asp:EntityDataSource>
    <asp:EntityDataSource ID="edsDefinition" runat="server" ConnectionString="name=CCEntities"
        DefaultContainerName="CCEntities" EnableDelete="True" EnableInsert="True" EnableUpdate="True"
        EntitySetName="Definitions" Where="!it.Disabled">
    </asp:EntityDataSource>
    <asp:EntityDataSource ID="edsPreferencesLists" runat="server" ConnectionString="name=CCEntities"
        DefaultContainerName="CCEntities" EnableDelete="True" EnableInsert="True" EnableUpdate="True"
        EntitySetName="PreferencesLists" Where="!it.Disabled">
    </asp:EntityDataSource>
    <%--<asp:ObjectDataSource ID="odsCountry" runat="server" SelectMethod="GetCountry" TypeName="BEGDC.CC.Web.CIS2.Overseas.CustomerInfo">
    </asp:ObjectDataSource>--%>
    <div id="dialog-company" title="Select a company" style="display: none">
        <label for="company-filter">
            Filter:
        </label>
        <input type="text" id="company-filter" style="width: 215px; margin-left: 15px;" />
        <span style="margin-left: 5px; display: inline-block; width: 16px; height: 16px;
            background-image: url(../../images/search.gif); cursor: pointer;"></span>
        <br />
        <div id="company-list-b" style="width: 330px; height: 165px; overflow: auto; margin-top: 10px;
            cursor: pointer; bo: 1px;">
        </div>
        <%--        <select id="company-list-c" style="display: none">
        </select>--%>
        <div id="company-list-c" style="display: none">
        </div>
    </div>
    <div id="dialog-department" title="Select a department" style="display: none">
        <label for="department-filter">
            Filter:
        </label>
        <input type="text" id="department-filter" style="width: 215px; margin-left: 15px;" />
        <span style="margin-left: 5px; display: inline-block; width: 16px; height: 16px;
            background-image: url(../../images/search.gif); cursor: pointer;"></span>
        <br />
        <div id="department-list-b" style="width: 330px; height: 165px; overflow: auto; margin-top: 10px;
            cursor: pointer; bo: 1px;">
        </div>
        <div id="department-list-c" style="display: none">
        </div>
    </div>
    <div id="create-company" title="Create a company (创建公司)" style="display: none">
        <ul class="CreatCompany">
            <li><span>Name (公司名称):<font class="Red">*</font></span>
                <input type="text" class="companyname-item" />
            </li>
            <li><span>Country (国家):<font class="Red">*</font></span>
                <select id="country-select">
                    <option value="0" class="country-item">--请选择--</option>
                    <%-- <asp:Repeater ID="Repeater14" runat="server" DataSourceID="odsCountry">
                        <ItemTemplate>
                            <option value='<%#Eval("CountryID") %>' class="country-item">
                                <%#Eval("Name") %>(<%#Eval("Description") %>)</option>
                        </ItemTemplate>
                    </asp:Repeater>--%>
                </select>
            </li>
            <li><span>Address (地址):</span>
                <input type="text" name="CreateCompanyAddress" id="CreateCompanyAddress" />
            </li>
            <li><span>Telephone (电话):</span>
                <input type="text" name="CreateCompanyTel" id="CreateCompanyTel" />
            </li>
            <li><span>Fax (传真):</span>
                <input type="text" name="CreateCompanyFax" id="CreateCompanyFax" />
            </li>
            <li><span>Website (网址):</span>
                <input type="text" name="CreateCompanyWeb" id="CreateCompanyWeb" />
            </li>
            <li><span>Zip (邮编):</span>
                <input type="text" name="CreateCompanyZip" id="CreateCompanyZip" />
            </li>
            <li><span>Comment (备注):</span>
                <input type="text" name="CreateCompanyComment" id="CreateCompanyComment" />
            </li>
        </ul>
    </div>
    </form>
    <%--页面刷新时显示--%>
    <%--<div id="dialog-message" title="Loading..." style="display: none">
        <p>
            <br />
            <span class="entity-loading"></span><span>Operation in process, please wait...<br />
                <br />
                处理中, 请稍候。。。</span>
        </p>
    </div>--%>
</body>
</html>

<script type="text/javascript">
    $(function() {

        String.prototype.contains = function(it) { return this.indexOf(it) != -1; };

        var clearList = function() {
            $("#company-list-c div").each(function() {
                $(this).appendTo("#company-list-b");
            });
            //$("#company-list-b option:selected").each(function() {
            //    $(this).attr("selected", false);
            //});
        };

        var clearList1 = function() {
            $("#department-list-c div").each(function() {
                $(this).appendTo("#department-list-b");
            });
            //$("#company-list-b option:selected").each(function() {
            //    $(this).attr("selected", false);
            //});
        };

        if ($("#edSelect").length > 0) {

            $("#dialog-company").dialog({
                autoOpen: false,
                height: 310,
                width: 360,
                modal: true,
                buttons: {
                    "OK": function() {
                        var c = $("#company-list-b div.selected-bg").length;
                        if (c == 0) {
                            alert("Please select a company");
                            return false;
                        }
                        else {
                            var vs = $("#company-list-b div.selected-bg").attr('vv');
                            $("#company-list-a").val(vs);
                            $(this).dialog("close");
                            $("select").show();

                            var params = '{companyID:"' + vs + '"}';
                            if (vs != "") {
                                $.ajax({
                                    type: "POST",
                                    url: "CustomerInfo.aspx/GetAreaByCompanyID",
                                    data: params,
                                    dataType: "json",
                                    contentType: "application/json; charset=utf-8",
                                    success: function(result) {
                                        var res = result.d.split(';');
                                        $("#txt_Area").text(res[0]);
                                        $("#txt_Country").text(res[1]);
                                    },
                                    error: function(xhr, msg, e) {
                                        $("#txt_Area").text("");
                                        $("#txt_Country").text("");
                                    }
                                });
                            }
                        }
                    },
                    Cancel: function() {
                        $(this).dialog("close");
                        $("select").show();

                        //clearList();
                        //$("#company-filter").val("");
                    }
                },
                close: function() {

                    $("select").show();

                    //clearList();
                    //$("#company-filter").val("");
                }
            });

            $("#dialog-department").dialog({
                autoOpen: false,
                height: 310,
                width: 360,
                modal: true,
                buttons: {
                    "OK": function() {
                        var c = $("#department-list-b div.selected-bg").length;
                        if (c == 0) {
                            alert("Please select a department");
                            return false;
                        }
                        else {
                            var vs = $("#department-list-b div.selected-bg").attr('vv');
                            $(".select-department").val(vs);
                            $(this).dialog("close");
                            $("select").show();

                        }
                    },
                    Cancel: function() {
                        $(this).dialog("close");
                        $("select").show();

                    }
                },
                close: function() {
                    $("select").show();
                }
            });

            $("#create-company").dialog({
                autoOpen: false,
                height: 310,
                width: 360,
                modal: true,
                buttons: {
                    "Save": function() {
                        var n = $(".companyname-item").val();
                        var p = $("#country-select").val();
                        var p1 = $("#country-select").find("option:selected").text();
                        var message = "";
                        if (n == "") {
                            message += "Please write a company name\n";
                        }
                        if (p == "0") {
                            message += "Please select a country\n";
                        }
                        if (message != "") {
                            alert(message);
                            return false;
                        }

                        else {
                            var add = $("#CreateCompanyAddress").val();
                            var tel = $("#CreateCompanyTel").val();
                            var fax = $("#CreateCompanyFax").val();
                            var web = $("#CreateCompanyWeb").val();
                            var zip = $("#CreateCompanyZip").val();
                            var comment = $("#CreateCompanyComment").val();
                            var username = '<%=GetUser() %>';

                            var params = '{name:"' + n + '",countryID:"' + p + '",address:"' + add + '",tel:"' + tel + '",fax:"' + fax + '",web:"' + web + '",zip:"' + zip + '",description:"' + comment + '",cil:"' + username + '"}';
                            $.ajax({
                                type: "POST",
                                url: "CustomerInfo.aspx/CreateCompanyOver",
                                data: params,
                                dataType: "json",
                                contentType: "application/json; charset=utf-8",
                                success: function(result) {
                                    var res = result.d.split(';');
                                    $("select#company-list-a").append("<option value=" + res[0] + " selected>" + n + "</option>");
                                    $("#txt_Area").text(res[1]);
                                    $("#txt_Country").text(p1);
                                },
                                error: function(xhr, msg, e) {
                                    alert("wrong");
                                }
                            });
                            $(".companyname-item").val("");
                            $("#country-select").val("0");
                            $("#CreateCompanyAddress").val("");
                            $("#CreateCompanyTel").val("");
                            $("#CreateCompanyFax").val("");
                            $("#CreateCompanyWeb").val("");
                            $("#CreateCompanyZip").val("");
                            $("#CreateCompanyComment").val("");
                        }
                        $(this).dialog("close");
                    },
                    Cancel: function() {
                        $(".companyname-item").val("");
                        $("#country-select").val("0");
                        $("#CreateCompanyAddress").val("");
                        $("#CreateCompanyTel").val("");
                        $("#CreateCompanyFax").val("");
                        $("#CreateCompanyWeb").val("");
                        $("#CreateCompanyZip").val("");
                        $("#CreateCompanyComment").val("");
                        $(this).dialog("close");
                    }
                },
                close: function() {

                    $("select").show();
                }
            });

            $("#pickcompany").bind("click", function() {
                $(".div-item").bind("click", function() {
                    $(".div-item").removeClass('selected-bg');
                    $(this).addClass('selected-bg');
                });
                $("#dialog-company").dialog("open");
                $("select").hide();
            });
            $("#pick-department").bind("click", function() {
                $(".div-item").bind("click", function() {
                    $(".div-item").removeClass('selected-bg');
                    $(this).addClass('selected-bg');
                });
                $("#dialog-department").dialog("open");
                $("select").hide();
            });

            $("#newcompany").bind("click", function() {
                $("#create-company").dialog("open");
                $(".entity-gender").hide();
                $(".select-company").hide();
                $(".select-department").hide();
                $(".entity-level").hide();
                $(".train_select").hide();
                $(".customer-degree").hide();
                $(".entity-definition").hide();
                $(".listPreferencesLists1").hide();
                $(".listPreferencesValues1").hide();
                $(".listPreferencesLevels1").hide();
                var roles = '<%=GetRoleIDs() %>';
                var params = '{roles:"' + roles + '"}';
                $.ajax({
                    type: "POST",
                    url: "CustomerInfo.aspx/GetCountrySelect",
                    data: params,
                    dataType: "json",
                    contentType: "application/json; charset=utf-8",
                    success: function(result) {
                        var countryObj = jQuery.parseJSON(result.d);
                        var optioncountrystring = "";
                        for (var item in countryObj) {
                            optioncountrystring += "<option class=\"country-item\" value=\"" + countryObj[item] + "\" >" + item + "</option>";
                        }
                        $("#country-select").html(optioncountrystring);
                    },
                    error: function(xhr, msg, e) {
                        alert("error");
                    }
                });

            });


            $("#company-filter").bind("change", function() {
                var v = $(this).val().toLowerCase();
                if (v == '') {
                    clearList();
                }
                else {
                    $("#company-list-c div").each(function() {
                        if ($(this).text().toLowerCase().contains(v))
                            $(this).appendTo("#company-list-b");
                    });
                    $("#company-list-b div").each(function() {
                        if (!$(this).text().toLowerCase().contains(v))
                            $(this).appendTo("#company-list-c");
                    });
                    $("#company-list-b div").each(function() {
                        $(this).removeClass('selected-bg');
                    });
                }
            });

            $("#department-filter").bind("change", function() {
                var v = $(this).val().toLowerCase();
                if (v == '') {
                    clearList1();
                }
                else {
                    $("#department-list-c div").each(function() {
                        if ($(this).text().toLowerCase().contains(v))
                            $(this).appendTo("#department-list-b");
                    });
                    $("#department-list-b div").each(function() {
                        if (!$(this).text().toLowerCase().contains(v))
                            $(this).appendTo("#department-list-c");
                    });
                    $("#department-list-b div").each(function() {
                        $(this).removeClass('selected-bg');
                    });
                }
            });
        }
    });
</script>

